#----------------------------
# Name: Rachel Ayotte
# Project: Madlibs.py
# Period: 2
# Start Date: 9/17/2013
# Last Revision Date: 9/17/2013
# Version: 1.0.0
#----------------------------

swearFilter = ["dumb",
               "stupid",
               "retard",
			   "fuck",
			   "hell",
			   "bitch",
			   "cunt",
			   "tits",
			   "ass",
			   "asshat",
			   "shit",
			   "poop",
			   "fart",
			   "dammit",
			   "goddamn",
			   "dick",
			   "penis",
			   "vagina",
			   "pussy",
			   "pussey",
			   "shitty",
			   "sex",
			   "fag",
			   "faggot",
			   "swag",
			   "swaggy",
			   "fucked",
			   "fucking",
			   "fucker",
			   "sweg",
			   "swagger",]

def displayStartScreen():
    print "Madlibs"
    raw_input("Press Enter to Continue")
    
def displayEndScreen():
    print "Goodbye"
    raw_input("Press Enter to Exit")

def getMenuOption(maxOption):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter Number or Q> ")
        option = option.upper()
        for num in range(1, maxOption+1):
            if option == str(num):
                goodOption = True
        if option == 'Q':
            goodOption = True
        if not goodOption:
            print "Please pick a valid option!"
    return option
        
def menu(options):
    print "------Please Select a Story------"
    print " [1] The End of the Day"
    print " [2] My New Pet"
    print " [3] My Day"
    print " [Q] Quit"
    print "----------------------------------"
    option = getMenuOption(options)
    return option
    
def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearFilter:
            goodWord = True
        else:
            print "Naughty player...please be polite."
        if not goodWord:
            print "Try again"
    return word
    
def getNumber(prompt, max = "", min = ""):
    num = ""
    goodNum = False
    while not goodNum:
        isNum = True
        num = raw_input(prompt)
        for character in num:
            if character not in "0123456789":
                isNum = False
        if min != "":
            if isNum:
                if float(num) < min:
                    isNum = False
        if max != "":
            if isNum:
                if float(num) > max:
                    isNum = False
        if isNum:
            goodNum = True
        else:
            print "Not a valid number, try again."
    return num
        
def story1():
    place1 = getWord("Enter a place: ")
    adjective1 = getWord("Enter an adjective: ")
    verb2 = getWord("Enter an action verb: ")
    monster = getWord("Enter some kind of monster: ")
    verb3 = getWord("Enter an action verb: ")
    room = getWord("Enter a room in a house: ")
    verb4 = getWord("Enter an action verb: ")
    noun1 = getWord("Enter a noun: ")
    verb5 = getWord("Enter an verb: ")
    adjective2 = getWord("Enter an adjective: ")
    superhero = getWord("Enter a superhero: ")
    verb6 = getWord("Enter an verb: ")
    emotion = getWord("Enter an emotion: ")
    story = "It was near the end of the day at"
    story += " " + place1 + ", "
    story += "and it was getting"
    story += " " + adjective1 + ". "
    story += "This started to scare me. I"
    story += " " + verb2 + " to the house thinking it was safe. But there was"
    story += " " + monster + " there waiting for me! I"
    story += " " + verb3 + " and locked myself in the"
    story += " " + room + " and cried in the corner. Suddenly there was a loud"
    story += " " + verb4 + " on the door. I was scared for my"
    story += " " + noun1 + " and just then the door"
    story += " " + verb5 + ". There stood the " + monster + " and he looked"
    story += " " + adjective2 + ". I thought I was going to die when"
    story += " " + superhero + " flew in and"
    story += " " + verb6 + " the day. I was"
    story += " " + emotion + ". The End."
    print story
    
def story2():
    name = getWord("Enter a name: ")
    age = getNumber("Enter a number: ")
    adjective1 = getWord("Enter an adjective: ")
    place = getWord("Enter a place: ")
    adjective2 = getWord("Enter an adjective: ")
    story = "I got a new pet and I named it"
    story += " " + name + ". "
    story += "I think " + name + " is"
    story += " " + age + " years old"
    story += " and it is" + adjective1 + ". "
    story += "I took" + name + " to"
    story += " " + place + ". It ran away. I was"
    story += " " + adjective2 + "."
    print story

def story3():
	verb1 = getWord("Enter a verb: ")
	animal = getWord("Enter a type of animal: ")
	noun = getWord("Enter a noun: ")
	game = getWord("Enter a game: ")
	adjective1 = getWord("Enter an adjective: ")
	place = getWord("Enter a place: ")
	story = "Today, when I got out of bed, the first thing I did was"
	story += " " + verb1 + ". Then I fed my pet"
	story += " " + animal + ". It was time to go visit my"
	story += " " + noun + "and we played"
	story += " " + game + ". We ended up getting into a fight and one of my"
	story += " " + noun + "got"
	story += " " + adjective1 + ". We rushed him to the"
	story += " " + place + ". He was fine. The end."
	print story

def run():
    displayStartScreen()
    choice = ""
    while choice != 'Q':
        choice = menu(3)
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == '3':
			story3()
        elif choice == 'Q':
            displayEndScreen()
        else:
            print "Something Awful Ocurred...yell at programmer!"
    exit()
run()